﻿using System;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using WorkItem = VisualWip.Core.WorkItem;

namespace VisualWip.TFS2010Providers
{
    public class WorkItemListQuery : WorkItemQueryBase
    {
        protected override Collection<WorkItem> RunGetWork(TfsWorkItemWorkProvider workItemWorkProvider)
        {
            var workItemCollection = workItemWorkProvider.WorkItemStore.Query(QueryText,
                                                                              workItemWorkProvider.QueryContext);
            return
                WorkItemTransformer.Transform(workItemCollection,DownloadDisplayFieldsOnly);
        }

        protected override int RunGetWorkCount(TfsWorkItemWorkProvider workItemWorkProvider)
        {
            var query = new Query(workItemWorkProvider.WorkItemStore, QueryText, workItemWorkProvider.QueryContext);
            return query.RunCountQuery();
        }
    }
}